package com.wanhe.base.util;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.widget.TextView;

/**
 * Created by Administrator on 2016/5/17.
 */
public class TypefaceUtil {
	public static void setTypeface(Context context, TextView textView, String path) {
        Typeface typeFace = getTypeFace(context, path);
        if (ObjectUtil.checkObject(typeFace)) {
            textView.setTypeface(typeFace);// 设置字体
        }
	}

	public static Typeface getTypeFace(Context context, String path) {
		if (TextUtils.isEmpty(path))
			return null;
		AssetManager mgr = context.getAssets();// 得到AssetManager
		Typeface tf = Typeface.createFromAsset(mgr, path);// 根据路径得到Typeface
		return tf;
	}
}
